Skip to content

[fmoe][gfx950] Add GLM-5.2 MXFP8/MXFP4 moe tune config#4074

Closed
zejunchen-zejun wants to merge 7 commits into
mainfrom
zejun/glm5.2_fp8_tune_moe_0703
Closed

[fmoe][gfx950] Add GLM-5.2 MXFP8/MXFP4 moe tune config#4074
zejunchen-zejun wants to merge 7 commits into
mainfrom
zejun/glm5.2_fp8_tune_moe_0703

Conversation

@zejunchen-zejun

Copy link
Copy Markdown
Contributor

GLM-5.2 runs its MoE as MXFP8 (per_1x32, e8m0 block scale) after online requant. Without a tuned fmoe config the runtime fell back to the CK-tile mfma path (mfma_moe1/2_afp8_wfp8) instead of the faster FlyDSL MXFP8 a8w8 kernels. Add tuned + matching untuned configs so the FlyDSL path is picked up by default via model_configs/ auto-merge.

Coverage: gfx950 (cu_num=256), model_dim=6144, expert=257, topk=9, q_type=per_1x32, a/w=fp8_e4m3fn, token 1..32768 for both inter_dim=512 (tp4) and inter_dim=256 (tp8). All rows err1/err2=0.0%.

Kept as a new file (not the existing a8w8_blockscale_tuned_fmoe_glm5.csv, which is the per_1x128 CK path) since the quant scheme differs.

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

GLM-5.2 runs its MoE as MXFP8 (per_1x32, e8m0 block scale) after online
requant. Without a tuned fmoe config the runtime fell back to the CK-tile
mfma path (mfma_moe1/2_afp8_wfp8) instead of the faster FlyDSL MXFP8 a8w8
kernels. Add tuned + matching untuned configs so the FlyDSL path is picked
up by default via model_configs/ auto-merge.

Coverage: gfx950 (cu_num=256), model_dim=6144, expert=257, topk=9,
q_type=per_1x32, a/w=fp8_e4m3fn, token 1..32768 for both
inter_dim=512 (tp4) and inter_dim=256 (tp8). All rows err1/err2=0.0%.

Kept as a new file (not the existing a8w8_blockscale_tuned_fmoe_glm5.csv,
which is the per_1x128 CK path) since the quant scheme differs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zejunchen-zejun
zejunchen-zejun requested review from a team and Copilot July 3, 2026 09:26
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 4074 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GLM-5.2 MoE model-specific tuned/untuned config CSVs for gfx950 MXFP8 (per_1x32) so runtime selection prefers the FlyDSL MXFP8 a8w8 kernels instead of falling back to the slower CK-tile MFMA path.

Changes:

  • Add a new untuned MoE shape list for GLM-5.2 MXFP8 per_1x32 (inter_dim 512 and 256; tokens 1..32768).
  • Add a new tuned MoE config for gfx950 (cu_num=256) mapping those shapes to specific FlyDSL stage1/stage2 kernel names and measured timings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
aiter/configs/model_configs/mxfp8_untuned_fmoe_glm5_2.csv Adds GLM-5.2 MXFP8 per_1x32 untuned shape keys to support config lookup/tuning workflows.
aiter/configs/model_configs/mxfp8_tuned_fmoe_glm5_2.csv Adds gfx950 tuned kernel selections for those shapes to drive FlyDSL MXFP8 path selection via auto-merge.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

gfx950,256,512,6144,512,257,9,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float8_e4m3fn,QuantType.per_1x32,1,0,32,0,265.9479,flydsl_moe1_afp8_wfp8_bf16_t32x64x256_w2_gui_kw2_fp8,0.0%,161.7576,flydsl_moe2_afp8_wfp8_bf16_t32x128x128_atomic_persist,0.0%,427.7055,0,0,0,203.35,5692.69,
gfx950,256,1024,6144,512,257,9,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float8_e4m3fn,QuantType.per_1x32,1,0,64,0,297.0182,flydsl_moe1_afp8_wfp8_bf16_t64x128x256_w4_gui_fp8,0.0%,177.7574,flydsl_moe2_afp8_wfp8_bf16_t64x128x128_atomic_bnt2,0.0%,474.7756,0,0,0,366.38,5148.18,
gfx950,256,2048,6144,512,257,9,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float8_e4m3fn,QuantType.per_1x32,1,0,128,0,348.9894,flydsl_moe1_afp8_wfp8_bf16_t128x128x256_w4_gui_fp8,0.0%,246.1611,flydsl_moe2_afp8_wfp8_bf16_t64x128x128_atomic_sbm128,0.0%,595.1505,0,0,0,584.55,4138.63,
gfx950,256,4096,6144,512,257,9,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float8_e4m3fn,QuantType.per_1x32,1,0,64,0,529.8860000000001,flydsl_moe1_afp8_wfp8_bf16_t64x128x256_w4_bnt0_gui,0.0%,388.0813,flydsl_moe2_afp8_wfp8_bf16_t64x128x256_atomic_bnt2_persist,0.0%,917.9673,0,0,0,757.96,2724.34,
Companion to the MXFP8 configs already on this branch: adds the MXFP4
(per_1x32, a4w4, fp4x2 act+weight) fused-MoE tuning for GLM-5.2 on gfx950,
covering TP4 (inter_dim=512) and TP8 (inter_dim=256), tokens 1..32768 (32
rows). Auto-merged via model_configs/ glob; no aiter code change.

Dedup keeps one row per key = fastest measured (min us): FlyDSL where it
is fastest, CK where CK is fastest; redundant slower duplicates dropped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zufayu
zufayu requested a review from junhaha666 July 6, 2026 02:01
@zejunchen-zejun zejunchen-zejun changed the title [fmoe][gfx950] Add GLM-5.2 FP8 MXFP8 (per_1x32) MoE tuned configs [fmoe][gfx950] Add GLM-5.2 MXFP8/MXFP4 moe tune config Jul 6, 2026
gbyu-amd and others added 5 commits July 7, 2026 00:34
…glm5_fp4)

The GLM-5.2 MXFP4 (per_1x32) configs collided 32/32 on all shape-key
columns with the existing glm5_fp4_tuned_fmoe.csv (GLM-5/5.2 share MoE
dims: model_dim=6144, expert=257, topk=9). After #3946 that file already
carries FlyDSL-tuned primary rows plus CK flydsl_fallback rows for these
shapes, and its tuning is on par with (or better than) the re-tune here on
17/32 shapes. Keeping both would trip the fmoe config auto-merge duplicate
check (RuntimeError + source-file rewrite).

Remove mxfp4_{tuned,untuned}_fmoe_glm5_2.csv and rely on glm5_fp4. The
MXFP8 (per_1x32) configs are genuinely new (no existing GLM MXFP8 fmoe
config) and are kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The GLM-5.2 MXFP4 (per_1x32) shapes collide 1:1 with glm5_fp4_tuned_fmoe.csv
(GLM-5/5.2 share MoE dims). Rather than duplicate (which trips the fmoe
config auto-merge) or blindly overwrite, take the faster row per shape
between this tune (2026-07-03) and main's FlyDSL tune (#3946, 2026-07-06):
15/32 shapes switch to the faster rows from here, 17/32 keep main's, and the
CK flydsl_fallback rows are preserved. Total us over the 32 shapes drops to
14604.8 (vs main 14748.1 / this-tune-only 14668.8) — strictly better than
either alone. The standalone mxfp4_{tuned,untuned}_fmoe_glm5_2.csv are
removed; MXFP8 (per_1x32) configs are new and kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gbyu-amd added a commit that referenced this pull request Jul 7, 2026
…4074)

Add GLM-5.2 MXFP8 (per_1x32) tuned/untuned MoE configs and merge
best-of-both GLM-5.2 MXFP4 tuning into glm5_fp4_tuned_fmoe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zejunchen-zejun

Copy link
Copy Markdown
Contributor Author

this config merged into #4095

zufayu pushed a commit that referenced this pull request Jul 8, 2026
…FP4 MoE (#4095)

* Add per-token tuned configs for GLM-5.2-FP8 fp8 GEMM and MoE

Adds per-token quant tuned (and source untuned) configs for GLM-5.2-FP8
on gfx950 (TP4), complementing the block-scale (per_1x128) configs. Same
M/N/K shapes as the block-scale set, quantized per-token instead:

- a8w8_bpreshuffle GEMM: 4 shapes (N6144/K3072, N6144/K4096,
  N6144/K6144, N7168/K512), swept over M in {1..32768}.
- fused MoE (QuantType.per_Token): hidden_dim=6144, inter_dim=512,
  expert=257, topk=9, swept over tokens {1..32768}.

Both quant families coexist in the model_configs glob merge; the runtime
matches rows by q_type, so per-token and per_1x128 configs do not
collide. No code change required. Tuning completed with zero failures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Add tuned ptpc a8w8_bpreshuffle GEMM configs for GLM-5.2 N2624/K6144 and N4096/K2048

These two fp8 GEMM shapes were previously missing from the ptpc enumeration,
causing the server to fall back to default (untuned) configs. Tuned all 16 M
values {1..32768} for each on gfx950 (256 CU).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Drop glm5.2 ptpc GEMM rows duplicating existing tuned configs

Remove 37 shapes from the glm5.2 a8w8_bpreshuffle tuned/untuned files whose
(gfx,cu_num,M,N,K,q_dtype_w) already exist in other merged configs on main
(minimax_m3: N6144/K3072 + N6144/K6144; global default: 5x N7168/K512).
This keeps existing config files untouched and avoids the runtime merge
auto-dedup error. glm5.2 retains only shapes unique to it (59 rows).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* [fmoe][gfx950] Add GLM-5.2 MXFP8/MXFP4 moe tune config (cherry-pick #4074)

Add GLM-5.2 MXFP8 (per_1x32) tuned/untuned MoE configs and merge
best-of-both GLM-5.2 MXFP4 tuning into glm5_fp4_tuned_fmoe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* [fmoe][gfx950] Drop glm5.2 fp8 fmoe configs; keep only flydsl-over-flydsl in glm5_fp4

Per review:
1. Remove glm5.2_fp8_{tuned,untuned}_fmoe.csv (no longer needed).
2. In glm5_fp4_tuned_fmoe.csv, only let the merged GLM-5.2 MXFP4 rows override
   main when both sides are FlyDSL. Revert the 5 shapes where the incoming row
   used a CK (moe_ck2stages) kernel over main's FlyDSL row (inter256 token1/2,
   inter512 token4/16384/32768) back to main's FlyDSL config. The remaining 10
   overrides are FlyDSL-over-FlyDSL and are kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* [fmoe] Rename GLM-5.2 MXFP8 fmoe configs to <model>_<quant>_tuned_fmoe convention

mxfp8_{tuned,untuned}_fmoe_glm5_2.csv -> glm5_2_mxfp8_{tuned,untuned}_fmoe.csv
to match the model-first naming used by every other fmoe config
(e.g. glm5_fp4_tuned_fmoe.csv, minimax_m3_mxfp8_tuned_fmoe.csv). Content is
unchanged; the new names still contain the tuned_fmoe/untuned_fmoe substring
the config auto-merge globs on, and runtime selection is by shape-key content
not filename, so config lookup is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* [fmoe] Rename GLM-5.2 MXFP8 fmoe configs glm5_2 -> glm5

glm5_2_mxfp8_{tuned,untuned}_fmoe.csv -> glm5_mxfp8_{tuned,untuned}_fmoe.csv,
matching the glm5 prefix used by glm5_fp4_tuned_fmoe.csv. Pure rename; content
unchanged and the tuned_fmoe/untuned_fmoe substring is preserved so config
lookup is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* [Fix] exclude untuned_fmoe CSVs from CK 2stages prebuild enumeration

The prebuild variant enumerator globs "*tuned_fmoe*.csv", which also
matches "*untuned_fmoe*.csv" as a substring. Untuned CSVs describe
problem shapes to tune, not resolved kernels, and carry no kernelName
columns, so the flydsl-skip guard does not exclude them. Their rows then
fall through to CK 2stages codegen.

GLM-5.2 MXFP8 (Silu, per_1x32, f8/f8) is the first untuned combo that
also slips past the existing swiglu-skip, forcing prebuild to AOT-compile
a CK 2stages instance that has no working implementation:

  module_moe_ck2stages_f8_f8_preshuffle_on_b16_silu_per_1x32_mulWeightStage2
  threadwise_tensor_slice_transfer_v7r3_scatter.hpp: no matching call to 'unpack2'

Filter out any path containing "untuned" so untuned CSVs never feed the
prebuild enumerator. MXFP8 MoE is served by FlyDSL kernels (the tuned CSV
rows carry flydsl_* kernel names and are already skipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: zejunchen-zejun <zejun.chen@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants